<div class="btn-group pull-right" style="margin-right: 10px">
    <a class="btn btn-sm btn-twitter" href="{{ $downloadUrl }}" target="_blank"><i class="fa fa-download"></i> 导出</a>
</div>
@if(\Encore\Admin\Facades\Admin::user()->isRole('administrator'))
    <div class="btn-group pull-right" style="margin-right: 10px">
        <button class="btn btn-sm btn-warning sync"><i class="fa fa-retweet"></i>&nbsp;&nbsp;<span id="loading">库存同步</span></button>
    </div>
@endif
<script language="JavaScript" type="text/javascript">
    $(function () {
        $('.sync').on('click', function(e) {
            e.preventDefault();
            $.ajax({
                method: 'post',
                url: '/xqc/overseas-ba/box-fnsku-in-ajax',
                data: {
                    _token:"{{ csrf_token() }}",
                    action:'syncBoxFNSku'
                },
                beforeSend: function(){
                    $('#loading').text('同步中，请耐心等待。');
                    $('.sync').attr('disabled',true);
                },
                success: function (data) {
                    $('#loading').text('同步');
                    $('.sync').removeAttr('disabled');
                    $.pjax.reload('#pjax-container');
                    if (typeof data === 'object') {
                        if (data.status) {
                            toastr.success('提交成功 !');
                        } else {
                            swal(data.message, '', 'error');
                        }
                    }
                }
            });
        });
    });
</script>
